import React from "react";
import { connect } from "dva";
import { withRouter } from "dva/router";
import ProcessRecord from "@/components/flowdataDetail/TemplateProcessRecord";

@withRouter
@connect(({ FlowHandle }) => ({ flowHandleStore: FlowHandle }))
export default class Page extends React.Component {
  state = {};

  componentDidMount() {
    const {
      dispatch,
      location: {
        query: { processInstanceId = "" },
      },
    } = this.props;
    if (!processInstanceId) {
      return;
    }
    dispatch({
      type: "FlowHandle/getProcess",
      payload: { processInstanceId },
    });
    dispatch({
      type: "FlowHandle/getFlowRecords",
      payload: { processInstanceId },
    });
  }

  render() {
    const {
      processDetailData = {},
      flowRecords = [],
    } = this.props.flowHandleStore;
    const {
      location: {
        query: { processInstanceId = "" },
      },
    } = this.props;
    const { process = {} } = processDetailData;
    if (!processInstanceId) {
      return <>无流程实例数据</>;
    }
    return (
      <ProcessRecord
        style={{ overflow: "hidden" }}
        data={process}
        flowRecords={flowRecords}
        // handleTaskVisible={(label, visible, taskId) =>
        //   this.handleTaskVisible(label, visible, taskId, applyUserId)
        // }
        // customFormVisible={this.customFormVisible}
        // actype={this.actype}
      />
    );
  }
}
